{extend name="base" /}
{block name="content"}
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="{:url('index/welcome')}"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>cms</span>
            <span class="icon-angle-right"></span>
            <span>管理栏目</span>
            <span class="icon-angle-right"></span>
            <span>系统模型</span>
            <span class="icon-angle-right"></span>
            <span>管理数据表</span>
            <span class="icon-angle-right"></span>
            <span>{$tbname}</span>
            <span class="icon-angle-right"></span>
            <span>管理系统模型</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-form">
                <form class="layui-form" id="j_form">
                    <table class="m-table">
                        <thead>
                            <tr>
                                <th colspan="2">{$info ? '编辑' : '添加'}系统模型</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td width="15%"><label for="name">模型名称<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-long" name="name" id="name" placeholder="请输入模型名称" value="{$info.name}" /></td>
                            </tr>
                            <tr>
                                <td><label for="alias_name">模型别名</label></td>
                                <td><input type="text" class="u-ipt u-ipt-long" name="alias_name" id="alias_name" placeholder="请输入模型别名" value="{$info.alias_name}" /></td>
                            </tr>
                            <tr>
                                <td><label for="remark">备注</label></td>
                                <td><div class="m-textarea"><textarea name="remark" class="u-tarea" id="remark" placeholder="请输入备注">{$info.remark}</textarea></div></td>
                            </tr>
                            {if condition="count($fields)"}
                            <tr>
                                <td><label for="">字段管理</label></td>
                                <td>
                                    <table class="m-table m-fields">
                                        <thead>
                                            <tr>
                                                <th width="20%">字段标识</th>
                                                <th width="30%">字段名</th>
                                                <th width="10%">列表显示项</th>
                                                <th width="10%">前台录入项</th>
                                                <th width="10%">前台必填项</th>
                                                <th width="10%">后台录入项</th>
                                                <th width="10%">后台必填项</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            {foreach name="fields" item="v"}
                                            <tr>
                                                <td>{$v.f}<input type="hidden" name="ids[{$key}]" value="{$v.id}" /><input type="hidden" name="f[{$key}]" value="{$v.f}" /></td>
                                                <td><input type="text" name="fname[{$key}]" value="{$info && isset($info['field'][$v['id']]) ? $info['field'][$v['id']] : $v.fname}" class="u-ipt u-ipt-def"></td>
                                                <td><input type="checkbox" name="list_field[{$key}]" value="{$v.id}" lay-skin="primary"{if condition="$info && in_array($v['id'], $info['list_field'])"} checked{/if} /></td>
                                                <td><input type="checkbox" name="qenter[{$key}]" value="1" lay-skin="primary"{if condition="$info && in_array($v['id'], $info['qenter'])"} checked{/if} /></td>
                                                <td><input type="checkbox" name="qmust_enter[{$key}]" value="1" lay-skin="primary"{if condition="$info && in_array($v['id'], $info['qmust_enter'])"} checked{/if} /></td>
                                                <td><input type="checkbox" name="henter[{$key}]" value="1" lay-skin="primary"{if condition="$info && in_array($v['id'], $info['henter'])"} checked{/if} /></td>
                                                <td><input type="checkbox" name="hmust_enter[{$key}]" value="1" lay-skin="primary"{if condition="$info && in_array($v['id'], $info['hmust_enter'])"} checked{/if} /></td>
                                            </tr>
                                            {/foreach}
                                        </tbody>
                                    </table>
                                </td>
                            </tr>
                            {/if}
                        </tbody>
                    </table>
                    <div class="m-form-btn"><input type="hidden" name="id" value="{$info.id}"><input type="hidden" name="tid" value="{$tid}"><input type="hidden" name="tbname" value="{$tbname}"><button id="j_btn" class="u-btn">确定提交</button></div>
                </form>
            </div>
        </div>
    </div>
</div>
<input type="hidden" name="redirect_uri" value="{:url('index', ['tid' => $tid, 'tbname' => $tbname])}" />
{/block}
{block name="extrajs"}
{include file="public:upload"/}
{/block}